<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <button>B一下</button>
<script>
    function fun(){
        location.href = 'https://www.bilibili.com/';
    }
    let bth = document.querySelector('button');
    bth.addEventListener('click',fun);
</script>
</body>
</html>